package com.itheima.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.UserMapper;
import com.itheima.daomain.User;
import com.itheima.util.SessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @Descriptionn:test
 * @Create by:依然
 * @Date:2021/11/5 11:34
 */

/**
 * 模糊查询用户信息
 */
public class SelectLike {
    public PageInfo<User> findUserBySearchKey(int currentPage, String keyword) {
        //业务判断

        //调用dao层中的功能，查询信息
        System.out.println("findUserBySearchKey" +currentPage);
        PageHelper.startPage(currentPage, 5);
        SqlSession sqlSession = SessionFactoryUtils.getSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        List<User> userList = userMapper.selectLike(keyword);
        /* for (User user : userList) {
            System.out.println("findUserBySearchKey::"+ user);
        }*/
        PageInfo<User> pageInfo = new PageInfo<>(userList);
        return pageInfo;

    }
}
